package cn.tedu;

import java.io.*;
import java.util.Scanner;

/*用于复习字节流字符流*/
public class INSTERE {
    public static void main(String[] args) {
//        System.out.println("请您输入需要复制的文件夹:");
//        String a = new Scanner(System.in).nextLine();
//        System.out.println("请您输入一个新的文件名:");
//        String b =new Scanner(System.in).nextLine();

        //aaa(a,b);
        //bbb(a,b);
        manth();
    }

    private static void manth() {
        InputStream in = null;
        try{
            in = new FileInputStream(new File("D:/ready/1.txt"));
            int a;
            while((a=in.read())!=-1){
                System.out.println(a);
            }
        }catch(Exception e){
            e.printStackTrace();
        }finally{
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static void bbb(String a, String b) {
        Reader in = null;
        Writer out = null;
        try{
            in =new BufferedReader(new FileReader(a));
            out =new BufferedWriter(new FileWriter(b));
            int h;
            while((h=in.read())!=-1){
                out.write(h);
            }
            System.out.println("复制成功");
        }catch(Exception e){
            System.out.println("复制失败");
            e.printStackTrace();
        }finally{
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }

    private static void aaa(String a, String b) {
        InputStream in=null;
        OutputStream out=null;
        try{
            in = new BufferedInputStream(new FileInputStream(a));
            out = new BufferedOutputStream(new FileOutputStream(b));
            int g;
            while((g=in.read())!=-1){
                out.write(g);
            }
            System.out.println("恭喜您,复制文件成功!");
        }catch(Exception e){
            System.out.println("很抱歉失败了");
            e.printStackTrace();
        }finally{
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }

        }

    }
}
